interval = 0
time = 0

$("#sendCaptcha").click(e => {
    $("#sendCaptcha").addClass("am-disabled")
    
    postSendVerifyEmail(d => {
        time = 9
        $("#sendCaptcha").text("冷却：" + (time + 1) + "s")
        interval = setInterval(() => {
            if(time == 0) {
                $("#sendCaptcha").text("获取验证码")
                $("#sendCaptcha").removeClass("am-disabled")
                clearInterval(interval)
                return;
            }
            $("#sendCaptcha").text("冷却：" + time + "s")
            --time
        }, 1000)
    }, d => {
        $("#sendCaptcha").removeClass("am-disabled")
        alert("验证码发送失败\n" + d.msg)
    })
})

$("#btn-reg").click(e => {
    verifyStu($("#captcha")[0].value, d => {
        alert("认证成功")
        window.location.href = "contest.html"
    }, d => {
        alert("认证失败\n" + d.msg)
    })
})


getUserInfo(d => {
    $("#stuid")[0].value = d.stuid
    $("#email")[0].value = $("#stuid")[0].value + "@std.uestc.edu.cn"
}, d => {})